# Maintainer: Miles Alan <m@milesalan.com>
pkgname=mepo
pkgver=0.4.1
pkgrel=0
pkgrel=1
arch="aarch64 x86_64" # Limited by zig aport
url="https://git.sr.ht/~mil/mepo"
pkgdesc="Fast, simple, and hackable OSM map viewer for Linux"
source="
$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz
"
license="GPL-3.0-or-later"
depends="jq curl ncurses font-inconsolata-nerd"
makedepends="zig>=0.9.1 curl-dev sdl2-dev sdl2_image-dev sdl2_ttf-dev sdl2_gfx-dev"
subpackages="
	$pkgname-xorg:xorg:noarch
	$pkgname-wayland:wayland:noarch
	$pkgname-framebuffer:framebuffer:noarch
"

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	zig build -Drelease-safe=true ${cputarget:+-Dcpu="$cputarget"}
}

check() {
	zig build test
}

xorg() {
	pkgdesc="$pkgname (xorg)"
	depends="$depends $pkgname xdotool dmenu"
	mkdir -p "$subpkgdir"
}

wayland() {
	pkgdesc="$pkgname (wayland)"
	depends="$depends $pkgname bemenu"
	mkdir -p "$subpkgdir"
}

framebuffer() {
	pkgdesc="$pkgname (framebuffer)"
	depends="$depends $pkgname directfb mesa-gl kbd vis"
	mkdir -p "$subpkgdir"
}

package() {
	mkdir -p "$pkgdir/usr/bin" "$pkgdir/usr/share/applications" "$pkgdir/usr/share/pixmaps"
	install zig-out/bin/* "$pkgdir/usr/bin/"
	install zig-out/share/applications/mepo.desktop "$pkgdir/usr/share/applications/"
	install zig-out/share/pixmaps/mepo.png "$pkgdir/usr/share/pixmaps/"
}

sha512sums="
0baf41980e9b4c85276019151e258c7588261c825e59b159af4fa00e5f821df26fbc5598382dc7f9ce3bb395986d867d5dfdf519c211e5a4c2bee0062b44becf  mepo-0.4.1.tar.gz
"
